{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.read_csv('All Earthquakes.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>latitude</th>\n",
       "      <th>longitude</th>\n",
       "      <th>depth</th>\n",
       "      <th>mag</th>\n",
       "      <th>magType</th>\n",
       "      <th>nst</th>\n",
       "      <th>gap</th>\n",
       "      <th>dmin</th>\n",
       "      <th>rms</th>\n",
       "      <th>...</th>\n",
       "      <th>updated</th>\n",
       "      <th>place</th>\n",
       "      <th>type</th>\n",
       "      <th>horizontalError</th>\n",
       "      <th>depthError</th>\n",
       "      <th>magError</th>\n",
       "      <th>magNst</th>\n",
       "      <th>status</th>\n",
       "      <th>locationSource</th>\n",
       "      <th>magSource</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2017-01-30T23:41:27.870Z</td>\n",
       "      <td>38.814667</td>\n",
       "      <td>-122.794167</td>\n",
       "      <td>2.77</td>\n",
       "      <td>1.00</td>\n",
       "      <td>md</td>\n",
       "      <td>15.0</td>\n",
       "      <td>68.0</td>\n",
       "      <td>0.006748</td>\n",
       "      <td>0.01</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:43:07.082Z</td>\n",
       "      <td>5km NW of The Geysers, California</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.30</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.020</td>\n",
       "      <td>5.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>nc</td>\n",
       "      <td>nc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2017-01-30T23:32:12.810Z</td>\n",
       "      <td>33.620500</td>\n",
       "      <td>-116.633333</td>\n",
       "      <td>12.52</td>\n",
       "      <td>0.78</td>\n",
       "      <td>ml</td>\n",
       "      <td>19.0</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.038290</td>\n",
       "      <td>0.30</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:35:54.456Z</td>\n",
       "      <td>8km NNE of Anza, CA</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.98</td>\n",
       "      <td>1.67</td>\n",
       "      <td>0.366</td>\n",
       "      <td>14.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>ci</td>\n",
       "      <td>ci</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017-01-30T23:13:32.520Z</td>\n",
       "      <td>38.791832</td>\n",
       "      <td>-122.825500</td>\n",
       "      <td>-0.83</td>\n",
       "      <td>1.19</td>\n",
       "      <td>md</td>\n",
       "      <td>6.0</td>\n",
       "      <td>179.0</td>\n",
       "      <td>0.047340</td>\n",
       "      <td>0.10</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:15:14.174Z</td>\n",
       "      <td>6km WNW of The Geysers, California</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>1.47</td>\n",
       "      <td>3.78</td>\n",
       "      <td>0.190</td>\n",
       "      <td>2.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>nc</td>\n",
       "      <td>nc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2017-01-30T23:07:07.350Z</td>\n",
       "      <td>33.792333</td>\n",
       "      <td>-116.158333</td>\n",
       "      <td>5.40</td>\n",
       "      <td>1.79</td>\n",
       "      <td>ml</td>\n",
       "      <td>51.0</td>\n",
       "      <td>63.0</td>\n",
       "      <td>0.052810</td>\n",
       "      <td>0.19</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:17:49.970Z</td>\n",
       "      <td>10km NNE of Indio, CA</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.54</td>\n",
       "      <td>0.190</td>\n",
       "      <td>27.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>ci</td>\n",
       "      <td>ci</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2017-01-30T23:02:30.680Z</td>\n",
       "      <td>33.791167</td>\n",
       "      <td>-116.152667</td>\n",
       "      <td>5.97</td>\n",
       "      <td>2.62</td>\n",
       "      <td>ml</td>\n",
       "      <td>68.0</td>\n",
       "      <td>63.0</td>\n",
       "      <td>0.057610</td>\n",
       "      <td>0.17</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:29:08.980Z</td>\n",
       "      <td>10km NE of Indio, CA</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.20</td>\n",
       "      <td>0.70</td>\n",
       "      <td>0.228</td>\n",
       "      <td>25.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>ci</td>\n",
       "      <td>ci</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       time   latitude   longitude  depth   mag magType   nst  \\\n",
       "0  2017-01-30T23:41:27.870Z  38.814667 -122.794167   2.77  1.00      md  15.0   \n",
       "1  2017-01-30T23:32:12.810Z  33.620500 -116.633333  12.52  0.78      ml  19.0   \n",
       "2  2017-01-30T23:13:32.520Z  38.791832 -122.825500  -0.83  1.19      md   6.0   \n",
       "3  2017-01-30T23:07:07.350Z  33.792333 -116.158333   5.40  1.79      ml  51.0   \n",
       "4  2017-01-30T23:02:30.680Z  33.791167 -116.152667   5.97  2.62      ml  68.0   \n",
       "\n",
       "     gap      dmin   rms  ...                   updated  \\\n",
       "0   68.0  0.006748  0.01  ...  2017-01-30T23:43:07.082Z   \n",
       "1   80.0  0.038290  0.30  ...  2017-01-30T23:35:54.456Z   \n",
       "2  179.0  0.047340  0.10  ...  2017-01-30T23:15:14.174Z   \n",
       "3   63.0  0.052810  0.19  ...  2017-01-30T23:17:49.970Z   \n",
       "4   63.0  0.057610  0.17  ...  2017-01-30T23:29:08.980Z   \n",
       "\n",
       "                                place        type horizontalError depthError  \\\n",
       "0   5km NW of The Geysers, California  earthquake            0.30       0.56   \n",
       "1                 8km NNE of Anza, CA  earthquake            0.98       1.67   \n",
       "2  6km WNW of The Geysers, California  earthquake            1.47       3.78   \n",
       "3               10km NNE of Indio, CA  earthquake            0.24       0.54   \n",
       "4                10km NE of Indio, CA  earthquake            0.20       0.70   \n",
       "\n",
       "   magError  magNst     status  locationSource magSource  \n",
       "0     0.020     5.0  automatic              nc        nc  \n",
       "1     0.366    14.0  automatic              ci        ci  \n",
       "2     0.190     2.0  automatic              nc        nc  \n",
       "3     0.190    27.0  automatic              ci        ci  \n",
       "4     0.228    25.0  automatic              ci        ci  \n",
       "\n",
       "[5 rows x 22 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['time']=pd.to_datetime(df['time'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>latitude</th>\n",
       "      <th>longitude</th>\n",
       "      <th>depth</th>\n",
       "      <th>mag</th>\n",
       "      <th>magType</th>\n",
       "      <th>nst</th>\n",
       "      <th>gap</th>\n",
       "      <th>dmin</th>\n",
       "      <th>rms</th>\n",
       "      <th>...</th>\n",
       "      <th>updated</th>\n",
       "      <th>place</th>\n",
       "      <th>type</th>\n",
       "      <th>horizontalError</th>\n",
       "      <th>depthError</th>\n",
       "      <th>magError</th>\n",
       "      <th>magNst</th>\n",
       "      <th>status</th>\n",
       "      <th>locationSource</th>\n",
       "      <th>magSource</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2017-01-30 23:41:27.870000+00:00</td>\n",
       "      <td>38.814667</td>\n",
       "      <td>-122.794167</td>\n",
       "      <td>2.77</td>\n",
       "      <td>1.00</td>\n",
       "      <td>md</td>\n",
       "      <td>15.0</td>\n",
       "      <td>68.0</td>\n",
       "      <td>0.006748</td>\n",
       "      <td>0.01</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:43:07.082Z</td>\n",
       "      <td>5km NW of The Geysers, California</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.30</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.020</td>\n",
       "      <td>5.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>nc</td>\n",
       "      <td>nc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2017-01-30 23:32:12.810000+00:00</td>\n",
       "      <td>33.620500</td>\n",
       "      <td>-116.633333</td>\n",
       "      <td>12.52</td>\n",
       "      <td>0.78</td>\n",
       "      <td>ml</td>\n",
       "      <td>19.0</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.038290</td>\n",
       "      <td>0.30</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:35:54.456Z</td>\n",
       "      <td>8km NNE of Anza, CA</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.98</td>\n",
       "      <td>1.67</td>\n",
       "      <td>0.366</td>\n",
       "      <td>14.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>ci</td>\n",
       "      <td>ci</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017-01-30 23:13:32.520000+00:00</td>\n",
       "      <td>38.791832</td>\n",
       "      <td>-122.825500</td>\n",
       "      <td>-0.83</td>\n",
       "      <td>1.19</td>\n",
       "      <td>md</td>\n",
       "      <td>6.0</td>\n",
       "      <td>179.0</td>\n",
       "      <td>0.047340</td>\n",
       "      <td>0.10</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:15:14.174Z</td>\n",
       "      <td>6km WNW of The Geysers, California</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>1.47</td>\n",
       "      <td>3.78</td>\n",
       "      <td>0.190</td>\n",
       "      <td>2.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>nc</td>\n",
       "      <td>nc</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2017-01-30 23:07:07.350000+00:00</td>\n",
       "      <td>33.792333</td>\n",
       "      <td>-116.158333</td>\n",
       "      <td>5.40</td>\n",
       "      <td>1.79</td>\n",
       "      <td>ml</td>\n",
       "      <td>51.0</td>\n",
       "      <td>63.0</td>\n",
       "      <td>0.052810</td>\n",
       "      <td>0.19</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:17:49.970Z</td>\n",
       "      <td>10km NNE of Indio, CA</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.54</td>\n",
       "      <td>0.190</td>\n",
       "      <td>27.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>ci</td>\n",
       "      <td>ci</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2017-01-30 23:02:30.680000+00:00</td>\n",
       "      <td>33.791167</td>\n",
       "      <td>-116.152667</td>\n",
       "      <td>5.97</td>\n",
       "      <td>2.62</td>\n",
       "      <td>ml</td>\n",
       "      <td>68.0</td>\n",
       "      <td>63.0</td>\n",
       "      <td>0.057610</td>\n",
       "      <td>0.17</td>\n",
       "      <td>...</td>\n",
       "      <td>2017-01-30T23:29:08.980Z</td>\n",
       "      <td>10km NE of Indio, CA</td>\n",
       "      <td>earthquake</td>\n",
       "      <td>0.20</td>\n",
       "      <td>0.70</td>\n",
       "      <td>0.228</td>\n",
       "      <td>25.0</td>\n",
       "      <td>automatic</td>\n",
       "      <td>ci</td>\n",
       "      <td>ci</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                              time   latitude   longitude  depth   mag  \\\n",
       "0 2017-01-30 23:41:27.870000+00:00  38.814667 -122.794167   2.77  1.00   \n",
       "1 2017-01-30 23:32:12.810000+00:00  33.620500 -116.633333  12.52  0.78   \n",
       "2 2017-01-30 23:13:32.520000+00:00  38.791832 -122.825500  -0.83  1.19   \n",
       "3 2017-01-30 23:07:07.350000+00:00  33.792333 -116.158333   5.40  1.79   \n",
       "4 2017-01-30 23:02:30.680000+00:00  33.791167 -116.152667   5.97  2.62   \n",
       "\n",
       "  magType   nst    gap      dmin   rms  ...                   updated  \\\n",
       "0      md  15.0   68.0  0.006748  0.01  ...  2017-01-30T23:43:07.082Z   \n",
       "1      ml  19.0   80.0  0.038290  0.30  ...  2017-01-30T23:35:54.456Z   \n",
       "2      md   6.0  179.0  0.047340  0.10  ...  2017-01-30T23:15:14.174Z   \n",
       "3      ml  51.0   63.0  0.052810  0.19  ...  2017-01-30T23:17:49.970Z   \n",
       "4      ml  68.0   63.0  0.057610  0.17  ...  2017-01-30T23:29:08.980Z   \n",
       "\n",
       "                                place        type horizontalError depthError  \\\n",
       "0   5km NW of The Geysers, California  earthquake            0.30       0.56   \n",
       "1                 8km NNE of Anza, CA  earthquake            0.98       1.67   \n",
       "2  6km WNW of The Geysers, California  earthquake            1.47       3.78   \n",
       "3               10km NNE of Indio, CA  earthquake            0.24       0.54   \n",
       "4                10km NE of Indio, CA  earthquake            0.20       0.70   \n",
       "\n",
       "   magError  magNst     status  locationSource magSource  \n",
       "0     0.020     5.0  automatic              nc        nc  \n",
       "1     0.366    14.0  automatic              ci        ci  \n",
       "2     0.190     2.0  automatic              nc        nc  \n",
       "3     0.190    27.0  automatic              ci        ci  \n",
       "4     0.228    25.0  automatic              ci        ci  \n",
       "\n",
       "[5 rows x 22 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['Year_month']=df['time'].apply(lambda x: x.strftime('%b-%y')) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "data1=df.groupby('type').count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "data1=data1.reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>type</th>\n",
       "      <th>time</th>\n",
       "      <th>latitude</th>\n",
       "      <th>longitude</th>\n",
       "      <th>depth</th>\n",
       "      <th>mag</th>\n",
       "      <th>magType</th>\n",
       "      <th>nst</th>\n",
       "      <th>gap</th>\n",
       "      <th>dmin</th>\n",
       "      <th>...</th>\n",
       "      <th>updated</th>\n",
       "      <th>place</th>\n",
       "      <th>horizontalError</th>\n",
       "      <th>depthError</th>\n",
       "      <th>magError</th>\n",
       "      <th>magNst</th>\n",
       "      <th>status</th>\n",
       "      <th>locationSource</th>\n",
       "      <th>magSource</th>\n",
       "      <th>Year_month</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>earthquake</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>5139</td>\n",
       "      <td>5785</td>\n",
       "      <td>5776</td>\n",
       "      <td>...</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>4118</td>\n",
       "      <td>8317</td>\n",
       "      <td>5636</td>\n",
       "      <td>5747</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "      <td>8323</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>explosion</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>34</td>\n",
       "      <td>34</td>\n",
       "      <td>34</td>\n",
       "      <td>...</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>34</td>\n",
       "      <td>58</td>\n",
       "      <td>34</td>\n",
       "      <td>34</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ice quake</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>other event</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>quarry blast</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>...</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           type  time  latitude  longitude  depth   mag  magType   nst   gap  \\\n",
       "0    earthquake  8323      8323       8323   8323  8323     8323  5139  5785   \n",
       "1     explosion    58        58         58     58    58       58    34    34   \n",
       "2     ice quake    40        40         40     40    40       40     0     1   \n",
       "3   other event     4         4          4      4     4        4     0     0   \n",
       "4  quarry blast    51        51         51     51    51       51    51    51   \n",
       "\n",
       "   dmin  ...  updated  place  horizontalError  depthError  magError  magNst  \\\n",
       "0  5776  ...     8323   8323             4118        8317      5636    5747   \n",
       "1    34  ...       58     58               34          58        34      34   \n",
       "2     1  ...       40     40                1          40         1       1   \n",
       "3     0  ...        4      4                0           4         0       0   \n",
       "4    51  ...       51     51               51          51        51      51   \n",
       "\n",
       "   status  locationSource  magSource  Year_month  \n",
       "0    8323            8323       8323        8323  \n",
       "1      58              58         58          58  \n",
       "2      40              40         40          40  \n",
       "3       4               4          4           4  \n",
       "4      51              51         51          51  \n",
       "\n",
       "[5 rows x 23 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "data1=data1[['type','time']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### rename the colum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "data1.columns.values[1]='count'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>type</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>earthquake</td>\n",
       "      <td>8323</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>explosion</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ice quake</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>other event</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>quarry blast</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           type  count\n",
       "0    earthquake   8323\n",
       "1     explosion     58\n",
       "2     ice quake     40\n",
       "3   other event      4\n",
       "4  quarry blast     51"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([<matplotlib.axes._subplots.AxesSubplot object at 0x000001DE3328BC88>],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEFCAYAAAAPCDf9AAAABHNCSVQICAgI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vvyNXDOzjDj0zcwy4tA3M8tIre/TH/YkXU3hW8KTKHyH4ACwOSJ21bVjVlfpv4tJwNaIeLuoPicifly/ntWepBlARMS29DMqc4BfRMTjde5a3UlaGxGL692PwfhCbhFJfwF8DlhP4TsFUPguwUJgfUTcW6++DTeS7oiIR+rdj1qQdCewFNgFTAe+EhGb0roXIuL6evavliQtp/DbWSOBDuAG4GngM8ATEbGifr2rLUmn324uYCbwJEBEfLbmnaqAQ7+IpH8ArouId0+rnw/sjIjm+vRs+JG0LyKurHc/akHSz4CPR8TbkpqAjcC6iHhQ0o6I+FhdO1hD6b2YDlwAvA40RsSbkn6Hwr+Cpta1gzUk6QUKvxv2HQqjAgIeo3CSSET8pH69G5iHd071PnAFsPe0+uVpXVYkvTTQKmBiLftSZyP6h3QiYo+km4GNkj5C6Z8W+TDri4j3gGOSfhkRbwJExD9Lyu3/kRbgK8DXgT+LiBcl/fNwDft+Dv1TfRXYImk3sD/VrgSuAr484FYfXhOB2cCR0+oC/m/tu1M3r0uaHhEvAqQz/j8EVgO/V9+u1dw7ki6MiGPA7/cXJV1KZidGEfE+cL+kv0nTg3wAMnXYd7CWIuLHkv4VhZ+AnkQh3LqBbensJjc/BC7uD7tikp6ufXfqZjHQV1yIiD5gsaT/WZ8u1c0fRMRv4ETo9RsFtNWnS/UVEd3AAkm3Am/Wuz/leEzfzCwjvk/fzCwjDn0zs4w49M3MMuLQNzPLiEPfzCwj/x/nJiQo/6N0iwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data1.plot(kind='bar',subplots=True,)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Plotting using Plotly API"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import plotly \n",
    "import chart_studio.plotly as py\n",
    "import plotly.graph_objs as go\n",
    "#Setting plotly credentials\n",
    "py.sign_in('username','key')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Gizmo-QA\\Anaconda3\\lib\\site-packages\\IPython\\core\\display.py:694: UserWarning:\n",
      "\n",
      "Consider using IPython.display.IFrame instead\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~mhd9/15.embed\" height=\"525px\" width=\"100%\"></iframe>"
      ],
      "text/plain": [
       "<chart_studio.tools.PlotlyDisplay object>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = [go.Scatter(\n",
    "        x=data1['type'],\n",
    "        y=data1['count'],\n",
    "        name = 'lines+markers'\n",
    "           \n",
    "    )\n",
    "       \n",
    "       ]\n",
    "layout = go.Layout(\n",
    "title='<b>Number Of Calamities</b>',\n",
    "xaxis=dict(title='Type',color = ('Black')),\n",
    "yaxis=dict(title='Counts',color = ('Black'))\n",
    ")\n",
    "fig = go.Figure(data=data, layout=layout)\n",
    "py.iplot(fig,filename='Earthquakes')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~mhd9/15.embed\" height=\"525px\" width=\"100%\"></iframe>"
      ],
      "text/plain": [
       "<chart_studio.tools.PlotlyDisplay object>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fig = go.Figure([go.Bar(x=data1['type'], y=data1['count'])])\n",
    "py.iplot(fig,filename='Earthquakes')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "colors = [\"rgb(0,116,217)\",\"rgb(255,65,54)\",\"rgb(133,20,75)\",\"rgb(255,133,27)\",\"lightgrey\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['text'] = 'Type: '+df['type']  + '<br>' +\\\n",
    " 'Place: '+df['place']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "types = data1['type'].tolist()\n",
    "len(types)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### i was trying with mpl Basemap but could not import the package, then i tried with plotly"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "_NamespacePath(['C:\\\\Users\\\\Gizmo-QA\\\\Anaconda3\\\\lib\\\\site-packages\\\\mpl_toolkits'])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import importlib\n",
    "importlib.import_module('mpl_toolkits').__path__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "#from mpl_toolkits.basemap import Basemap"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## New code:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## finding the latitudes  and longitudes by type"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8323\n",
      "58\n",
      "40\n",
      "4\n",
      "51\n"
     ]
    }
   ],
   "source": [
    "for i in range(len(types)):\n",
    "    #lim = types[i]\n",
    "    df_sub = df.loc[df.type==types[i],:]\n",
    "    print(len(df_sub))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "earthquake\n",
      "explosion\n",
      "ice quake\n",
      "other event\n",
      "quarry blast\n"
     ]
    }
   ],
   "source": [
    "for i in range(len(types)):\n",
    "    print(types[i])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "cases = []\n",
    "for i in range(len(types)):\n",
    "    lim = types[i]\n",
    "    df_sub = df.loc[df.type==types[i],:]\n",
    "    cases.append(go.Scattergeo(\n",
    "        lon = df_sub['longitude'],\n",
    "        lat = df_sub['latitude'],\n",
    "        text = df_sub['text'],\n",
    "        name = types[i] + ' : '+str(len((df_sub))),\n",
    "        marker = go.scattergeo.Marker(\n",
    "            color = colors[i],\n",
    "            sizemode = 'area'\n",
    "                )\n",
    "    ) )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~mhd9/17.embed\" height=\"525px\" width=\"100%\"></iframe>"
      ],
      "text/plain": [
       "<chart_studio.tools.PlotlyDisplay object>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "    \n",
    "layout = dict(\n",
    "        title = '<b>Most Calamities</b>  <br>(Hover for details)',\n",
    "        #colorbar = True,\n",
    "        showlegend = True,\n",
    "        geo = go.layout.Geo(\n",
    "        showframe = False,\n",
    "        showcoastlines = True,\n",
    "        showcountries = True,\n",
    "        showland = True,\n",
    "        landcolor = 'rgb(217, 217, 217)',\n",
    "        subunitwidth=1,\n",
    "        countrywidth=1,\n",
    "        subunitcolor=\"rgb(255, 255, 255)\",\n",
    "        countrycolor=\"rgb(255, 255, 255)\"\n",
    "        \n",
    "        ),\n",
    "    )\n",
    "\n",
    "fig = go.Figure( data=cases, layout=layout )\n",
    "py.iplot( fig, validate=False, filename='Eqack 1', fileopt='overwrite' )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Update(Oct 8): Updated the code with latest plot.ly references. Thanks to Mai (@maihao14) for pointing out the issue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
